function out = menufun(flag,s,y,param,glob,options)

% Parameters
w = param.w;

sigma = param.sigma;
epsilon = param.epsilon;
D       = param.D;
Y       = param.C;

A       = param.A;

switch flag
    case 'bounds'
        kpmin   = ones(size(s,1),1)*glob.mink;
        kpmax   = ones(size(s,1),1)*glob.maxk;
        out     = [kpmin,kpmax];
    case 'F'
        a       = param.A*exp(s(:,2));               
        q       = y/Y;
        p       = upsilonp(q,param)*D;
        out     = (p.*y - (w./a).*y);
    case 'p'
        q         = y/Y;
        out       = upsilonp(q,param)*D;
    case 'L'
        out       = y./(param.A*exp(s(:,2)));
    case 'C'
        L       = y./(param.A*exp(s(:,2)));
        %dL      = max(L - s(:,1),0);
        
        dL      = abs(L - s(:,1)*(1 - param.delta));
        dL      = dL./s(:,1);
        dL      = dL.^2;
        dL      = dL.*s(:,1);
        dL(s(:,1) == 0) = 0;
                
        
        out     = param.phi_L*dL;
end

end


